﻿using System;

namespace 观察者模式
{
    internal class Cat
    {
        private string name;
        private string color;

        public Cat(string name, string color)
        {
            this.name = name;
            this.color = color;
        }

        public void CatComming()
        {
            Console.WriteLine(color + "颜色的" + "猫：" + name + "来了");
            if (CatComeEvent != null)
                CatComeEvent();
        }

        public event Action CatComeEvent; //声明一个事件
    }
}